//添加自定义主栏
function addCustomDimensionWin(){
	var advancedRowWindow_ = new Ext.Window({	
		width:670,	
		height: 500,
		layout: "border",
		title:'添加自定义主栏',
		modal: true,
		border:false,
		id: "customV_win_",
		closeAction: 'close',
		defaults:{animate:false},
		items: [{
			height:608,
			width:200,
			id: 'tree-panel-dimensions',
			autoScroll: true,
			collapsible: true,
			split: true,
			margins: '2 2 2 2',
			useArrows:true,
			rootVisible : false,
			region:"west",
			xtype: 'treepanel',
			root: {text: '主栏指标',draggable: false,id: '-1',isRoot:true},
			loader: new Ext.tree.TreeLoader({ 
				dataUrl: getRootPath()+'/summaryReport.report?decorate=no',
				listeners:{beforeload:function(treeLoader, node){
				if(node.attributes.isRoot==true){
					this.baseParams.method = "getRoot";
				}else{
					this.baseParams.method = "getChilds";
				}
				this.baseParams.xmlId = xml_id_;
				this.baseParams.tableName = node.attributes.table;
				this.baseParams.pid = node.attributes.val;
				this.baseParams.level = node.attributes.level;
				this.baseParams.dir = node.attributes.d;
				this.baseParams.time = node.attributes.time;
				this.baseParams.currentTime = jQuery("#currentTime").val();
				this.baseParams.currentTimeWeiBiao = jQuery("#currentTimeWeiBiao").val();
				this.baseParams.isDimensions = 'true';
			}}
			}),
			listeners:{
				click:function(node){
					if(node.attributes.val!='-1'){
						var o = new Object();
							o.text='$' + node.attributes.table + '.' + node.attributes.val;
							addquery(o,'selRowSql_');
						}
					}
			}
		},{
			region:'center',
			width:320,
			height: 500,
			margins: '2 2 0 2',
			items:[{
				title:'高级模式',
				layout: 'table',
				border:false,
				bodyStyle:'padding:10px 10px 10px 20px',
				layoutConfig: {columns:4},
				defaults:{frame:false,style:'padding:2px',minWidth: '60',style:{marginBottom: '10px'}},
				items:[
				       {
				    	   id:'selRowName_',
				    	   xtype:'textfield',
				    	   width  : 350,
				    	   colspan:4,
				    	   emptyText:'请输入自定义行名称',
				    	   allowBlank:false,
				    	   blankText:'自定义行名称不能为空'
				       },
				       {
				    	   xtype: "textarea",
				    	   id: "selRowSql_",
				    	   width  : 350,
				    	   height : 140,
				    	   enableKeyEvents: true,
				    	   hideLabel:true,
				    	   allowBlank:false,
				    	   blankText:'自定义行表达式不能为空',
				    	   colspan:4,
				    	   style: {
					    	   marginBottom: '10px',
					    	   imeMode:'disabled'		//屏蔽输入法
			    		   }
				       }		        		 
				       , {
				    	   xtype: "button",
				    	   text: "1",
				    	   style:
				    	   {
				    	   marginBottom: '5px'
				    	   },
				    	   handler: function(){addquery(this,'selRowSql_');}
				       }
				       , {
				    	   xtype: "button",
				    	   text: "2",
				    	   style:
				    	   {
				    	   marginBottom: '5px'
				    	   },
				    	   handler: function(){addquery(this,'selRowSql_');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: "3",
				    	   style:
				    	   {
				    	   marginBottom: '5px'
				    	   },
				    	   handler: function(){addquery(this,'selRowSql_');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: " + ",
				    	   style:
				    	   {
				    	   marginBottom: '5px'
				    	   },
				    	   handler: function(){addquery(this,'selRowSql_');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: "4",
				    	   style:
				    	   {
				    	   marginBottom: '5px'
				    	   },
				    	   handler: function(){addquery(this,'selRowSql_');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: "5",
				    	   style:
				    	   {
				    	   marginBottom: '5px'
				    	   },
				    	   handler: function(){addquery(this,'selRowSql_');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: "6",
				    	   handler: function(){addquery(this,'selRowSql_');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: " - ",
				    	   handler: function(){addquery(this,'selRowSql_');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: "7",
				    	   style:
				    	   {
				    	   marginBottom: '5px'
				    	   },
				    	   handler: function(){addquery(this,'selRowSql_');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: "8",
				    	   handler: function(){addquery(this,'selRowSql_');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: "9",
				    	   style:
				    	   {
				    	   marginBottom: '5px'
				    	   },
				    	   handler: function(){addquery(this,'selRowSql_');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: " * ",
				    	   handler: function(){addquery(this,'selRowSql_');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: "0",
				    	   handler: function(){addquery(this,'selRowSql_');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: " ( ",
				    	   handler: function(){addquery(this,'selRowSql_');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: " ) ",
				    	   handler: function(){addquery(this,'selRowSql_');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: " / ",
				    	   handler: function(){addquery(this,'selRowSql_');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: " 清除 ",
				    	   handler: function(){
				    	   Ext.getCmp('selRowSql_').setValue() == "";
				       }
				       }
				       ,{
				    	   xtype: "button",
				    	   text: " 保存 ",
				    	   handler: function(){
				    	   if(!Ext.getCmp('selRowName_').validate())
				    	   {
				    		   return;
				    	   }
				    	   if(!Ext.getCmp('selRowSql_').validate())
				    	   {
				    		   return;
				    	   }
				    	   jQuery("#droppableV").find('ul').append("<li tabindex=1 onkeydown='keyDown(this)'  oncontextmenu='showmenuV(this)' label='"+Ext.getCmp('selRowName_').getValue()+"' customV='true' express='"+"("+Ext.getCmp('selRowSql_').getValue()+")"+"' class='v'>"+Ext.getCmp('selRowName_').getValue()+"</li>");
				    	   enable_move();
				    	   Ext.getCmp('customV_win_').close();
				       }
				       }
				       ,{
				    	   xtype: "button",
				    	   text: " 保存并继续添加 ",
				    	   colspan:2,
				    	   minWidth:150,
				    	   handler: function(){
				    	   if(!Ext.getCmp('selRowName_').validate())
				    	   {
				    		   return;
				    	   }
				    	   if(!Ext.getCmp('selRowSql_').validate())
				    	   {
				    		   return;
				    	   }
				    	   jQuery("#droppableV").find('ul').append("<li onkeydown='keyDown(this)' oncontextmenu='showmenuV(this)' label='"+Ext.getCmp('selRowName_').getValue()+"' customV='true' express='"+"("+Ext.getCmp('selRowSql_').getValue()+")"+"' class='v'>"+Ext.getCmp('selRowName_').getValue()+"</li>");
				    	   enable_move();
				       }
				       }
				       ]
			}]
		}
		]
	});//Ext.Window
	Ext.getCmp('customV_win_').show();
}

//修改自定义主栏
function updateCustomDimensionWin(ev){
	var advancedRowWindow_ = new Ext.Window({	
		width:670,	
		height: 500,
		layout: "border",
		title:'修改自定义主栏',
		modal: true,
		border:false,
		id: "customV_win_modify",
		closeAction: 'close',
		items: [{
			height:608,
			width:200,
			id: 'tree-panel-dimensions-modify',
			autoScroll: true,
			collapsible: true,
			split: true,
			margins: '2 2 2 2',
			useArrows:true,
			rootVisible : false,
			region:"west",
			xtype: 'treepanel',
			root: {text: '主栏指标',draggable: false,id: '-1',isRoot:true},
			loader: new Ext.tree.TreeLoader({ 
				dataUrl: getRootPath()+'/summaryReport.report?decorate=no',
				listeners:{beforeload:function(treeLoader, node){
				if(node.attributes.isRoot==true){
					this.baseParams.method = "getRoot";
				}else{
					this.baseParams.method = "getChilds";
				}
				this.baseParams.xmlId = xml_id_;
				this.baseParams.tableName = node.attributes.table;
				this.baseParams.pid = node.attributes.val;
				this.baseParams.level = node.attributes.level;
				this.baseParams.dir = node.attributes.d;
				this.baseParams.time = node.attributes.time;
				this.baseParams.currentTime = jQuery("#currentTime").val();
				this.baseParams.currentTimeWeiBiao = jQuery("#currentTimeWeiBiao").val();
				this.baseParams.isDimensions = 'true';
			}}
			}),
			listeners:{
				click:function(node){
					if(node.attributes.val!='-1'){
						var o = new Object();
							o.text='$' + node.attributes.table + '.' + node.attributes.val;
							addquery(o,'selRowSql_modify');
						}
					}
			}
		},{
			region:'center',
			width:320,
			height: 500,
			margins: '2 2 0 2',
			items:[{
				title:'高级模式',
				layout: 'table',
				border:false,
				bodyStyle:'padding:10px 10px 10px 20px',
				layoutConfig: {columns:4},
				defaults:{frame:false,style:'padding:2px',minWidth: '60',style:{marginBottom: '10px'}},
				items:[
				       {
				    	   id:'selTitleName_hidden',
				    	   xtype:'hidden',
				    	   width  : 350,
				    	   colspan:4
				       },{
				    	   id:'selRowName_modify',
				    	   xtype:'textfield',
				    	   width  : 350,
				    	   colspan:4,
				    	   emptyText:'请输入自定义行名称',
				    	   allowBlank:false,
				    	   blankText:'自定义行名称不能为空'
				       },
				       {
				    	   xtype: "textarea",
				    	   id: "selRowSql_modify",
				    	   width  : 350,
				    	   height : 140,
				    	   enableKeyEvents: true,
				    	   hideLabel:true,
				    	   allowBlank:false,
				    	   blankText:'自定义行表达式不能为空',
				    	   colspan:4,
				    	   style: {
					    	   marginBottom: '10px',
					    	   imeMode:'disabled'		//屏蔽输入法
			    		   }
				       }		        		 
				       , {
				    	   xtype: "button",
				    	   text: "1",
				    	   style:
				    	   {
				    	   marginBottom: '5px'
				    	   },
				    	   handler: function(){addquery(this,'selRowSql_modify');}
				       }
				       , {
				    	   xtype: "button",
				    	   text: "2",
				    	   style:
				    	   {
				    	   marginBottom: '5px'
				    	   },
				    	   handler: function(){addquery(this,'selRowSql_modify');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: "3",
				    	   style:
				    	   {
				    	   marginBottom: '5px'
				    	   },
				    	   handler: function(){addquery(this,'selRowSql_modify');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: " + ",
				    	   style:
				    	   {
				    	   marginBottom: '5px'
				    	   },
				    	   handler: function(){addquery(this,'selRowSql_modify');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: "4",
				    	   style:
				    	   {
				    	   marginBottom: '5px'
				    	   },
				    	   handler: function(){addquery(this,'selRowSql_modify');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: "5",
				    	   style:
				    	   {
				    	   marginBottom: '5px'
				    	   },
				    	   handler: function(){addquery(this,'selRowSql_modify');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: "6",
				    	   handler: function(){addquery(this,'selRowSql_modify');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: " - ",
				    	   handler: function(){addquery(this,'selRowSql_modify');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: "7",
				    	   style:
				    	   {
				    	   marginBottom: '5px'
				    	   },
				    	   handler: function(){addquery(this,'selRowSql_modify');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: "8",
				    	   handler: function(){addquery(this,'selRowSql_modify');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: "9",
				    	   style:
				    	   {
				    	   marginBottom: '5px'
				    	   },
				    	   handler: function(){addquery(this,'selRowSql_modify');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: " * ",
				    	   handler: function(){addquery(this,'selRowSql_modify');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: "0",
				    	   handler: function(){addquery(this,'selRowSql_modify');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: " ( ",
				    	   handler: function(){addquery(this,'selRowSql_modify');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: " ) ",
				    	   handler: function(){addquery(this,'selRowSql_modify');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: " / ",
				    	   handler: function(){addquery(this,'selRowSql_modify');}
				       }
				       ,{
				    	   xtype: "button",
				    	   text: " 清除 ",
				    	   colspan:2,
				    	   minWidth:160,
				    	   handler: function(){
				    	   Ext.getCmp('selRowSql_modify').setValue() == "";
				       }
				       }
				       ,{
				    	   xtype: "button",
				    	   text: " 确认修改 ",
				    	   colspan:2,
				    	   minWidth:160,
				    	   handler: function(){
				    	   if(!Ext.getCmp('selRowName_modify').validate())
				    	   {
				    		   return;
				    	   }
				    	   if(!Ext.getCmp('selRowSql_modify').validate())
				    	   {
				    		   return;
				    	   }
			    		   if(Ext.getCmp('selTitleName_hidden').getValue()=="true")  //未定义---表示维表标题
			    		   {
			    			   ev.outerHTML = "<LI onkeydown=keyDown(this) oncontextmenu=showmenuV(this) ondblclick='modify(this);' label='"
			    		   		+ Ext.getCmp('selRowName_modify').getValue()+"' table='"
			    		   		+ Ext.getCmp('selRowSql_modify').getValue()+"' column='undefined' leader='true' isblank='true' pid='undefined'><B><U>"
			    		   		+ Ext.getCmp('selRowName_modify').getValue()+"</U></B></LI>";
			    		   }else
			    		   {
				    		   if(ev.conditions != null){
				    			   ev.outerHTML = "<li onkeydown='keyDown(this)' oncontextmenu='showmenuV(this)' ondblclick='modify(this);' label='"+Ext.getCmp('selRowName_modify').getValue()+"' customV='true' express='"+"("+Ext.getCmp('selRowSql_modify').getValue()+")"+"' conditions=\""+Ext.getCmp('customV_win_modify').evObject.conditions+"\" class='v'>"+Ext.getCmp('selRowName_modify').getValue()+"</li>";
				    		   }else{
				    			   ev.outerHTML = "<li onkeydown='keyDown(this)' oncontextmenu='showmenuV(this)' ondblclick='modify(this);' label='"+Ext.getCmp('selRowName_modify').getValue()+"' customV='true' express='"+"("+Ext.getCmp('selRowSql_modify').getValue()+")"+"' class='v'>"+Ext.getCmp('selRowName_modify').getValue()+"</li>";
				    		   }
			    		   }
				    	   Ext.getCmp('customV_win_modify').close();
				       }
				       }
				       ]
			}]
		}
		]
	});
	Ext.getCmp('customV_win_modify').show();
}
	
